package com.smedi.ismedi.cronjob.api.feign;

import com.smedi.ismedi.cronjob.api.dto.request.JobInfoRequest;
import com.smedi.ismedi.cronjob.api.dto.response.JobInfoResponse;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author u
 */
@FeignClient("cronjob")
@Api(tags = {"定时任务操作接口"})
@RequestMapping(value = "/api/v1/cronjob/internal/job")
public interface RemoteJobInfoFeignApi {
    /**
     * 临时运行一个job
     *
     * @param jobInfoRequest
     * @return string
     */
    @RequestMapping(value = "/runJob")
    @ApiOperation(httpMethod = "POST", value = "临时运行一个job")
    ResponseData<Boolean> postRunJob(@RequestBody JobInfoRequest jobInfoRequest);

    /**
     * 停止一个job的运行
     *
     * @param jobInfoRequest
     * @return string
     */
    @RequestMapping(value = "/pauseJob")
    @ApiOperation(httpMethod = "POST", value = "停止一个job的运行")
    ResponseData<Boolean> postPauseJob(@RequestBody JobInfoRequest jobInfoRequest);

    /**
     * 恢复一个job的运行
     *
     * @param jobInfoRequest
     * @return string
     */
    @RequestMapping(value = "/resumeJob")
    @ApiOperation(httpMethod = "POST", value = "恢复一个job的运行")
    ResponseData<Boolean> postResumeJob(@RequestBody JobInfoRequest jobInfoRequest);

    /**
     * 在容器内刷新一个job，该动作不会修改job的运行状态
     *
     * @param jobInfoRequest
     * @return string
     */
    @RequestMapping(value = "/refreshJob")
    @ApiOperation(httpMethod = "POST", value = "重启一个job")
    ResponseData<Boolean> postRefreshJob(@RequestBody JobInfoRequest jobInfoRequest);

    /**
     * 在容器内刷新所有job，该动作不会修改job的运行状态
     *
     * @param jobInfoRequest
     * @return string
     */
    @RequestMapping(value = "/restartAllJob")
    @ApiOperation(httpMethod = "POST", value = "在容器内刷新所有job，该动作不会修改job的运行状态")
    ResponseData<List<JobInfoResponse>> postRestartAllJob(@RequestBody JobInfoRequest jobInfoRequest);

    /**
     * 新增一个job
     *
     * @param jobInfoRequest
     * @return string
     */
    @RequestMapping(value = "/insertJob")
    @ApiOperation(httpMethod = "POST", value = "新增一个job")
    ResponseData<JobInfoResponse> postInsertJob(@RequestBody JobInfoRequest jobInfoRequest);

    /**
     * 删除一个job
     *
     * @param jobInfoRequest
     * @return string
     */
    @RequestMapping(value = "/deleteJob")
    @ApiOperation(httpMethod = "POST", value = "删除一个job")
    ResponseData<Boolean> postDeleteJob(@RequestBody JobInfoRequest jobInfoRequest);

    /**
     * 修改一个job，运行中job不能修改，需要暂停后再修改
     *
     * @param jobInfoRequest
     * @return string
     */
    @RequestMapping(value = "/updateJob")
    @ApiOperation(httpMethod = "POST", value = "修改一个job，运行中job不能修改，需要暂停后再修改")
    ResponseData<JobInfoResponse> postUpdateJob(@RequestBody JobInfoRequest jobInfoRequest);

    /**
     * 获取一个job的信息
     *
     * @param jobInfoRequest
     * @return string string
     */
    @RequestMapping(value = "/getJob")
    @ApiOperation(httpMethod = "POST", value = "获取一个job的信息")
    ResponseData<JobInfoResponse> postGetJob(@RequestBody JobInfoRequest jobInfoRequest);

    /**
     * 获取所有job的信息
     *
     * @param jobInfoRequest
     * @return string
     */
    @RequestMapping(value = "/listJob")
    @ApiOperation(httpMethod = "POST", value = "获取所有job的信息")
    ResponseData<List<JobInfoResponse>> postListJob(@RequestBody JobInfoRequest jobInfoRequest);
}
